<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>

        <ui:composition template="mainlayout.xhtml">
            <ui:define name="content">
                <h:form>

                    <p:tabView>
                        <p:tab title="Request">
                            <h:panelGrid columns="1" style="width: 100%">
                                <p:tabView value="#{notificationView.requestsList}" var="req" orientation="left" style="width: 100%">
                                    <p:tab title="#{req.event.title}">
                                        <p:panel>
                                            <h:panelGrid style=" width: 100%" columns="2" columnClasses="oneThirdPercent,twoThirdPercent">
                                                <h:panelGrid style=" width: 100%" columns="1">
                                                    <h:outputText value="#{req.invitationMessage}"/>
                                                    <h:outputText value="Start: #{req.event.startDate}" >
                                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                    </h:outputText>
                                                    <h:outputText value="End: #{req.event.endDate}" >
                                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                    </h:outputText>
                                                    <h:outputText value="Place: #{req.event.place}" />
                                                    <h:outputText value="Description: #{req.event.description}" />
                                                    <h:outputText value="Created by: #{req.event.createdBy.name}" />

                                                </h:panelGrid>
                                                <p:dataList value="#{req.event.goingUsers}" var="cal" style="width:98%">
                                                    <f:facet name="header">
                                                        Going
                                                    </f:facet>
                                                    #{cal.user.username} - #{cal.user.name},#{cal.user.surname}
                                                </p:dataList>
                                            </h:panelGrid>
                                            <p:separator/>
                                            <h:panelGroup style="display:block; text-align:center">
                                                <p:commandButton action="#{eventView.accept(req)}" value="Accept" />
                                                <p:commandButton action="#{eventView.refuse(req)}" value="Refuse" />
                                            </h:panelGroup>
                                        </p:panel>
                                    </p:tab>
                                </p:tabView>
                            </h:panelGrid>
                        </p:tab>
                        <p:tab title="Suggestion">
                            <h:panelGrid columns="1" style="width: 100%">
                                <p:tabView value="#{notificationView.suggestionsList}" var="sug" orientation="left" style="width: 100%">
                                    <p:tab title="#{sug.event.title}">
                                        <p:panel>
                                            <h:panelGrid style=" width: 100%" columns="2" columnClasses="oneThirdPercent,twoThirdPercent">
                                                <h:panelGrid style=" width: 100%" columns="1">
                                                    <h:outputText value="Info for the Event:"/>
                                                    <h:outputText value="Start: #{sug.event.startDate}" >
                                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                    </h:outputText>
                                                    <h:outputText value="End: #{sug.event.endDate}" >
                                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                    </h:outputText>
                                                    <h:outputText value="Place: #{sug.event.place}" />
                                                    <h:outputText value="Description: #{sug.event.description}" />
                                                    <h:outputText value="Created by: #{sug.event.createdBy.name}" />

                                                </h:panelGrid>
                                                <h:panelGrid style=" width: 100%" columns="1">
                                                    <h:outputText value="Suggested date:"/>
                                                    <h:outputText value="Start: #{sug.startDate}" >
                                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                    </h:outputText>
                                                    <h:outputText value="End: #{sug.endDate}" >
                                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                    </h:outputText>

                                                </h:panelGrid>

                                            </h:panelGrid>
                                            <p:separator/>
                                            <h:panelGroup style="display:block; text-align:center">
                                                <p:commandButton action="#{eventView.acceptSuggestion(sug)}" value="Accept" />
                                                <p:commandButton action="#{eventView.refuseSuggestion(sug)}" value="Refuse" />
                                            </h:panelGroup>
                                        </p:panel>
                                    </p:tab>
                                </p:tabView>
                            </h:panelGrid>
                        </p:tab>
                        <p:tab title="Update">
                            <h:panelGrid columns="1" style="width: 100%">
                                <p:tabView value="#{notificationView.updatesList}" var="upd" orientation="left" style="width: 100%">
                                    <p:tab title="#{upd.event.title}">
                                        <p:panel>
                                            <h:panelGrid style=" width: 100%" columns="1">
                                                <h:outputText value="#{upd.message}"/>
                                                <h:outputText value="Start: #{upd.event.startDate}" >
                                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                </h:outputText>
                                                <h:outputText value="End: #{upd.event.endDate}" >
                                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                </h:outputText>
                                                <h:outputText value="Place: #{upd.event.place}" />
                                                <h:outputText value="Description: #{upd.event.description}" />
                                                <h:outputText value="Created by: #{upd.event.createdBy.name}" />

                                            </h:panelGrid>
                                            <p:separator/>
                                            <h:panelGroup style="display:block; text-align:center">
                                                <p:commandButton action="#{eventView.setReadUpdate(upd)}" value="Ok" />
                                                <p:commandButton action="#{eventView.changeParticipationUpdate(upd)}" value="Change Partecipation" />
                                            </h:panelGroup>
                                        </p:panel>
                                    </p:tab>
                                </p:tabView>
                            </h:panelGrid>
                        </p:tab>
                        <p:tab title="Bad Weather">
                            <h:panelGrid columns="1" style="width: 100%">
                                <p:tabView value="#{notificationView.badWeatherList}" var="bad" orientation="left" style="width: 100%">
                                    <p:tab title="#{bad.event.title}">
                                        <p:panel>
                                            <h:panelGrid style=" width: 100%" columns="2" columnClasses="twoThirdPercent, oneThirdPercent">
                                                <h:panelGrid style=" width: 100%" columns="1">
                                                    <h:outputText value="Info for the event:"/>
                                                    <h:outputText value="Start: #{bad.event.startDate}" >
                                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                    </h:outputText>
                                                    <h:outputText value="End: #{bad.event.endDate}" >
                                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                    </h:outputText>
                                                    <h:outputText value="Place: #{bad.event.place}" />
                                                    <h:outputText value="Description: #{bad.event.description}" />
                                                    <h:outputText value="Created by: #{bad.event.createdBy.name}" />

                                                </h:panelGrid>
                                                <h:panelGrid style=" width: 600px" columns="1">
                                                    <h:outputText value="Weather forecast for the event. Starting from #{bad.event.startDate}">
                                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
                                                    </h:outputText>
                                                    <p:dataTable var="weat" value="#{bad.event.weatherForecastList}">
                                                        <p:column headerText="Precipitation type">
                                                            <h:outputText value="#{weat.weather.precipitationType.description}" />
                                                        </p:column>

                                                        <p:column headerText="Wind speed">
                                                            <h:outputText value="#{weat.weather.windSpeed} m/s" />
                                                        </p:column>

                                                        <p:column headerText="Temperature">
                                                            <h:outputText value="#{weat.weather.temperature}°C" />
                                                        </p:column>

                                                        <p:column headerText="Clouds coverage">
                                                            <h:outputText value="#{weat.weather.cloudsCoverage}%" />
                                                        </p:column>
                                                    </p:dataTable>
                                                </h:panelGrid>
                                            </h:panelGrid>
                                            <p:separator/>
                                            <h:panelGroup style="display:block; text-align:center">
                                                <p:commandButton action="#{eventView.setRead(bad)}" value="Ok" />
                                                <p:commandButton action="#{eventView.changeParticipation(bad)}" value="Change partecipation" rendered="#{!eventView.isCreator(bad.event)}"/>
                                                <p:commandButton action="#{eventView.editEvent(bad.event)}" value="Edit event" rendered="#{eventView.isCreator(bad.event)}"/>
                                            </h:panelGroup>
                                        </p:panel>
                                    </p:tab>
                                </p:tabView>
                            </h:panelGrid>
                        </p:tab>
                    </p:tabView>


                </h:form>
            </ui:define>

        </ui:composition>

    </h:body>
</html>

